package com.tzy.note.base.thread.lambda;

/**
 * 推导Lambda表达式
 *      1.外部实现类
 *      2.静态内部类
 *      3.局部内部类
 *      4.匿名内部类
 *      5.Lambda表达式
 */

public class TestLambda1 {
    public static void main(String[] args) {
        //1.外部实现类
        ILike like = new Like();
        like.lambda();
        //2.静态内部类
        like = new Like2();
        like.lambda();

        //3.局部内部类
        class Like3 implements ILike{
            @Override
            public void lambda() {
                System.out.println("I like lambda-3");
            }
        }
        like = new Like3();
        like.lambda();

        //4.匿名内部类,没有类的名称,必须借助接口或者父类
        like = new ILike(){
            @Override
            public void lambda() {
                System.out.println("I like lambda-4");
            }
        };
        like.lambda();

        //5.Lambda表达式
        like = ()->System.out.println("I like lambda-5");
        like.lambda();
    }

    //2.静态内部类
    static class Like2 implements ILike{
        @Override
        public void lambda() {
            System.out.println("I like lambda-2");
        }
    }

}

//定义函数式接口
interface ILike{
    void lambda();
}
//1.外部实现类
class Like implements ILike{
    @Override
    public void lambda() {
        System.out.println("I like lambda-1");
    }
}

